const { defineConfig } = require('@vue/cli-service')

module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    port: 3000,
    proxy: {
      '/api': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        pathRewrite: {
          '^/api': '/api'
        },
        secure: false,
        ws: true,
        logLevel: 'debug'
      },
      '/uploads': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        secure: false,
        ws: false,
        logLevel: 'debug'
      }
    },
    client: {
      overlay: {
        errors: (error) => {
          // 过滤掉 ResizeObserver 错误
          if (error.message.includes('ResizeObserver')) {
            return false
          }
          return true
        },
        warnings: false
      }
    },
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
      'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'
    }
  },
  configureWebpack: {
    resolve: {
      fallback: {
        "path": false
      }
    }
  }
})
